home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 February
/
EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso
/
enigma
/
earcd
/
comm
/
comm2
/
ctsrc701.lha
/
libcryp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-12-01
|
991b
|
48 lines
/*
* libCryp.c
*
* Library of encryption (std) for Citadel.
*/
/*
* history
*
* 91????? HAW Hash moved to Tools.c.
* 87Aug06 HAW Hash added.
* 85Nov15 HAW Created.
*/
#include "ctdl.h"
/*
* contents
*
* crypte() encrypts/decrypts data blocks
*/
extern CONFIG cfg; /* Configuration variables */
/*
* crypte()
*
* encrypts/decrypts data blocks
*
* This was at first using a full multiply/add pseudo-random sequence
* generator, but 8080s don't like to multiply. Slowed down I/O
* noticably. Rewrote for speed.
*
* 84Sep04 HAW I'll just use it......
*/
void crypte(void *buf, unsigned len, unsigned seed)
{
static AN_UNSIGNED *b; /* Make this static for speed (I guess),*/
static int c, s; /* since register variables not around */
if( cfg.cryptSeed == 0 ) return;
seed = (seed + cfg.cryptSeed) & 0xFF;
b = (AN_UNSIGNED *) buf;
c = len;
s = seed;
for (; c; c--)
{
*b++ ^= s;
s = (s + CRYPTADD) & 0xFF;
}
}